#include<bits/stdc++.h>
using namespace std;
const int N = 300002;

int n;
int maxn[N][20];
int v;

inline int findmax(int l,int r){
    int x;
    if(l==r) x=0;
    else x = (int)log2(r-l);
    return max(maxn[l][x],maxn[r-(1<<x)+1][x]);
}

inline int query(int pos,int v){
    int left = 1,right = n, mid;
    // cout<<"----"<<pos<<' '<<v<<endl;
    while(left<right){
        mid = (right-left)/2+left;
        int q = max(findmax(pos-mid,pos-1),findmax(pos+1,pos+mid));
        // cout<<"**"<<mid<<' '<<q<<"\n";
        if(q>=v) right=mid;
        else left=mid+1;
    }
    if(left==n) return -1;
    return left;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&maxn[i][0]);
        maxn[i+n][0] = maxn[i+2*n][0] = maxn[i][0];
    }
    for(int len=1;len<=((int)log2(n)+1);len++){
        for(int j=1;j<=3*n;j++){
            maxn[j][len] = max(maxn[j][len-1],maxn[min(j+(1<<(len-1)),3*n)][len-1]);
        }
    }
    // for(int len=0;len<=((int)log2(n)+1);len++){
    //     for(int j=1;j<=3*n;j++){
    //         cout<<maxn[j][len]<<' ';
    //     }
    //     cout<<"\n";
    // }

    for(int i=1;i<=n;i++){
        scanf("%d",&v);
        printf("%d ",query(i+n,v));
    }
    return 0;
}